import { Component, ViewChild, Input, OnChanges, SimpleChanges } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatTableDataSource } from '@angular/material/table';

@Component({
    selector: 'op-material-table',
    templateUrl: './material-table.component.html'
})
export class MaterialTableComponent implements OnChanges {
    @Input() inputData: any;
    @Input() userName: string;
    dataSource: any;

    @ViewChild(MatPaginator, {static: false}) paginator: MatPaginator;
    displayedColumns = ['operation', 'name', 'loginName', 'gender', 'status'];

    ngOnChanges(changes: SimpleChanges): void {
        this.dataSource = new MatTableDataSource(this.inputData);
        this.dataSource.paginator = this.paginator;
    }
}